package com.shilei;

import com.shilei.common.ResourceMgr;
import com.shilei.util.Audio;

import java.awt.*;

/**
 * @description: 爆炸类
 * @author: 81271
 * @date: 2020-04-07 21:43
 */
public class Explode extends GameObject{
    public static int HEIGHT = ResourceMgr.explodes[0].getHeight();
    public static int WIDTH = ResourceMgr.explodes[0].getWidth();

    private int x;
    private int y;

    private int step = 0;


    private Boolean liveBl = true;

    public Explode(int x, int y) {
        this.x = x;
        this.y = y;

        GameModel.getInstance().gameObjectList.add(this);

        new Thread(() -> {
            new Audio("audio/explode.wav").play();
        }).start();
    }


    public void paint(Graphics g) {
        g.drawImage(ResourceMgr.explodes[step++], x, y, null);

        if (step >= ResourceMgr.explodes.length)  GameModel.getInstance().gameObjectList.remove(this);
    }


    @Override
    public int getHeight() {
        return HEIGHT;
    }

    @Override
    public int getWidth() {
        return WIDTH;
    }



}
